package cn.tianyigps.m7.beans;

import cn.tianyigps.m7.command.Command;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.util.Date;
import java.util.Map;

/**
 * Created with IDEA
 *
 * @description: 任务实体基类 其他类均需继承该类
 * @author: cui.guibin
 * @create: 2019/3/11 14:58
 **/
@Setter
@Getter
@ToString
public class  Task {

   // 任务id
   private String id;
   private String clientId;
   // 任务类型
   private String taskType;
   // 任务名
   private String taskName;
   // 下一个任务
   private Task nextTask;
   // 时间戳
   private Date time;
   // 扩展信息
   private Map<String,Object> params;
   public Task() {
      super();
   }
   public Task(String taskType, Task nextTask, Map<String, Object> params) {
      this.taskType = taskType;
      this.nextTask = nextTask;
      this.time = new Date();
      this.params = params;
   }
   public void copyValueToCommand(Command command){
      Map<String, Object> params = this.params;
      String equipmentId = (String) params.get("equipmentId");
      String content = (String) params.get("content");
      String cmdType = (String) params.get("cmdType");
      command.setEquipmentId(equipmentId);
      command.setContent(content);
      command.setEquipmentId(equipmentId);
      command.setCmdType(cmdType);


   }
}
